package io.renren.modules.app.controller;

import com.baomidou.mybatisplus.plugins.Page;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.TZnmhAppMenu;
import io.renren.modules.app.service.TZnmhAppMenuService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Program: renren-fast
 * @Package: io.renren.modules.mynj.controller
 * @ClassName: AppMenuController
 * @Description: AppMenu控制类
 * @Author: ShenPengPeng
 * @CreateDate: 2018-11-02 23:55
 * @Version: 1.0
 */
@RestController
@RequestMapping("/app/appmenu")
public class AppMenuController {
    @Autowired
    private TZnmhAppMenuService tZnmhAppMenuService;
    /**
     * 所有app菜单列表
     */
    @PostMapping("/list")
    @RequiresPermissions("app:menu:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tZnmhAppMenuService.selectTZnmhAppMenuByPage(params);
        return R.ok().put("page", page);
    }
    //删除菜单
    @PostMapping("/delete")
    @RequiresPermissions("app:menu:delete")
    public R delete(@RequestBody String[] menuIds){
        tZnmhAppMenuService.deleteBatch(menuIds);
        return R.ok();
    }
    //根据ID查询菜单
    @PostMapping("/queryMenuById")
    @RequiresPermissions("app:menu:select")
    public R queryMenuById(@RequestParam String menuId){


        TZnmhAppMenu tZnmhAppMenu = tZnmhAppMenuService.selectTZnmhAppMenuById(menuId);

        return R.ok().put("appMenu",tZnmhAppMenu);
    }
    /*//上传图片
    @RequestMapping("/uploadImg")
    public R uploadImg(){
        System.out.println("666666");

        return R.ok();
    }
    //获取新增修改页初始数据
    @PostMapping("/initData")
    public R getInitData(){
        List<Map<String,Object>> versions = appMenuService.getVersions();
        List<Map<String,String>> classifys = appMenuService.getMenuClassifys();

        return R.ok().put("classifys",classifys).put("versions",versions);
    }




    //保存菜单
    @PostMapping("/save")
    @RequiresPermissions("app:menu:save")
    public R save(@RequestBody AppMenuEntity appMenuEntity){



        return R.ok();
    }*/
}
